package 富婆梦.第一阶段.第七周IO流;

import java.nio.ByteBuffer;
import java.nio.IntBuffer;

/**
 * @ProjectName: java-learning
 * @Package: 富婆梦.第一阶段.第七周
 * @ClassName: IntBufferDemo
 * @Author: hemengjin
 * @Description: nio视图缓冲器
 * @Date:2021/9/12 22:57
 * @Version: 1.0
 */
public class IntBufferDemo {
    private static final int BSIZE = 1024;

    public static void main(String[] args) {
        ByteBuffer bb = ByteBuffer.allocate(BSIZE);
        IntBuffer ib = bb.asIntBuffer();
        //放入数组
        ib.put(new int[]{11,42,47,99,143,811,1016});
        //确定位置读和写
        System.out.println(ib.get(3));
        ib.put(3,1811);
        ib.flip();
        while (ib.hasRemaining()){
            int i = ib.get();
            System.out.println(i);
        }
    }
}
